package com.tjetc.service.impl;

import com.tjetc.dao.UserDao;
import com.tjetc.dao.impl.UserDaoImpl;
import com.tjetc.domain.User;
import com.tjetc.service.UserService;

import java.sql.SQLException;

public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    @Override
    public User getByPhone(String phone) {
        try {
            return userDao.getByPhone(phone);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public boolean add(User user) {
        try {
            userDao.add(user);
            return true;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public User getById(int id) {
        try {
            return userDao.getById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public boolean clearAccount(int id) {
        try {
            userDao.clearAccount(id);
            return true;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public Integer getMaxId() {
        try {
            return userDao.getMaxId();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }


}
